package com.zzl.bonds.ticket.constant.type;

import java.util.ArrayList;
import java.util.List;

/**
 * 审批类型字典值
 *
 * @author szsw
 * @date 2021/12/2 15:27:08
 */
@SuppressWarnings("unused")
public enum ApproveTypeEnum {

    /**
     * 1 开立,2开立撤回,4签收(开立签收审批),14 签收(转让签收审批),12开立签收撤回,13转让签收撤回,7 转让,8转让撤回10, 融资,11 兑付
     * 最大code：15
     */
    OPEN_EXAMING             ("1", "开立", "开立申请后核心企业内部审批", "ticket_open_id","开立"),
    OPEN_ROLLBACK            ("2", "开立撤回", "核心企业,开立申请通过后核心企业撤回票据审批", "ticket_open_id","撤回"),
    OPEN_BACKSPACE_CORE      ("3", "*开立供应商退票", "一级供应商开立签收后退票审批", "",""),
    SIGN_OPEN_TRANSFER       ("4", "签收", "开立/转让签收审批", "ticket_open_id","签收"),
    SIGN_OPEN_ROLLBACK       ("12", "开立签收撤回", "供应商操作:开立签收中 或 开立签收完成,审核核心企业的撤回票据的流程", "exception_id","撤回"),
    SIGN_TRANSFER_ROLLBACK   ("13", "转让签收撤回", "下级供应商操作:转让签收中 或 转让签收完成,审核上级的撤回票据的流程", "exception_id","撤回"),
    SIGN_OPEN_BACKSPACE      ("5", "*开立退票", "开立签收后的票据退票审批", "",""),
    SIGN_TRANSFER_BACKSPACE  ("6", "*转让退票", "转让签收后的票据退票审批", "",""),
    TRANSFER                 ("7", "转让", "签收后发起转让申请审批", "ticket_transfer_id","转让"),
    SIGN_TRANSFER            ("14", "签收", "转让签收审批", "ticket_transfer_id","签收"),
    TRANSFER_ROLLBACK        ("8", "转让撤回", "上级供应商操作：转让申请通过后，上级供应商撤回票的审批流程", "exception_id","撤回"),
    TRANSFER_BACKSPACE_SUPP  ("9", "*转让供应商退票", "下级供应商转让签收后退票审批", "",""),
    FINANCE                  ("10", "融资", "供应商申请融资审核", "ticket_finace_id","融资"),
    FINANCE_PLATFORM         ("15", "融资平台审核", "供应商申请融资平台审核", "","融资"),
    CASHING                  ("11", "兑付", "核心企业申请兑付审核", "ticket_cash_id","兑付"),
    ;

    private String code;
    private String name;
    private String description;
    private String approveColumnName;
    /**
     * 处理状态
     */
    private String approveStatusName;

    ApproveTypeEnum(String code, String name, String description, String approveColumnName, String approveStatusName) {
        this.code = code;
        this.name = name;
        this.description = description;
        this.approveColumnName = approveColumnName;
        this.approveStatusName = approveStatusName;
    }

    /**
     * 通过 code 获取 name
     *
     * @param code code
     * @return name
     */
    public static String getNameByCode(String code) {
        ApproveTypeEnum enumByCode = getEnumByCode(code);
        if (enumByCode == null) {
            return "";
        }
        return enumByCode.getName();
    }

    /**
     * 通过 code 获取 枚举值
     *
     * @param code code
     * @return 枚举值
     */
    public static ApproveTypeEnum getEnumByCode(String code) {
        for (ApproveTypeEnum statusEnum : ApproveTypeEnum.values()) {
            if (statusEnum.code.equals(code)) {
                return statusEnum;
            }
        }
        return null;
    }

    /**
     * 票据撤回key值集合，包括开立撤回、开立签收撤回、转让签收撤回、转让撤回
     *
     * @return 票据撤回key值集合
     */
    public static List<String> getWithdrawCode() {
        List<String> list = new ArrayList<>();
        list.add(ApproveTypeEnum.OPEN_ROLLBACK.getCode());
        list.add(ApproveTypeEnum.SIGN_OPEN_ROLLBACK.getCode());
        list.add(ApproveTypeEnum.SIGN_TRANSFER_ROLLBACK.getCode());
        list.add(ApproveTypeEnum.TRANSFER_ROLLBACK.getCode());
        return list;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public String getDescription() {
        return description;
    }

    public String getApproveColumnName() {
        return approveColumnName;
    }

    public String getApproveStatusName() {
        return approveStatusName;
    }
}
